<template>
	<view style="padding: 20rpx;background: #1c202b;height: 100vh;">
		<hx-navbar ref="hxnb" :config="config" />
		<view style="color: #FFFFFF;">您生成的图片如下</view>
		<image v-if="Image==''" src="../../static/zxczx.gif" mode="widthFix"
			style="margin:30rpx 0 ;border-radius: 20rpx;width: 100vw;">
		</image>
		<image v-if="Image!=''" :src="Image" mode="widthFix" style="margin:30rpx 0 ;border-radius: 20rpx;width: 100vw;"
			@click="showPic()">
		</image>
		<view style="margin-top:45rpx;margin-left: 10rpx;display: flex;justify-content:space-between">
			<button
				style="background:linear-gradient(135deg,#42e695,#3bb2b8); font-size: 30rpx;width: 720rpx;   height: 100rpx;color: #FFFFFF;line-height: 100rpx;"
				class="round cu-btn pingfang-Bold" @click="downLoadImg">
				保存
			</button>
		</view>
	</view>
</template>

<script>
	import {
		copyText,
		Debounce,
		saveImg
	} from '@/common/util.js'
	import baseurl from "@/common/config.js"
	export default {
		data() {
			return {
				config: {
					title: "生成结果",
					back: true,
					backgroundColor: '#1f232f',
					color: '#FFFFFF',
					// // #ifdef H5
					// backTabPage: '../index/person',
					// // #endif
				},

				Image: '',
			}
		},
		onLoad(e) {
			let a = JSON.parse(e.data)
			this.ersdw(a)
		},
		methods: {
			ersdw(a) {
				uni.request({
					url: baseurl + '/system/sysChatGpt/public/drawV3',
					data: {
						message: a.text,
						size: a.cichuns
					},
					method: "post",
					header: {
						'Content-type': 'application/x-www-form-urlencoded;',
					},
					success: (res) => {
						
						console.log(res, '重新自产自销');
						this.Image = res.data.result.data[0].url
					},
					fail: (error) => {
						console.log(res, '厨房古典风格')
					}
				});
			},
			// 预览图片
			showPic() {
				let arr = [this.Image]
				uni.previewImage({
					indicator: "none",
					urls: arr
				});
			},
			downLoadImg() {
				saveImg(this.Image)
			},
		}
	}
</script>

<style>

</style>
